package study.zhangbo.lock.distributed.redis;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

/**
 * Created by zhangbo on 2020/10/29.
 */
@Slf4j
@Component
public class LockDemonComponent implements ApplicationRunner {

    @Autowired
    private RedisLockUtils redisLockUtils;

    @Override
    public void run(ApplicationArguments arguments) throws Exception {
        log.info("开始启动分布式锁守护线程");
        Thread lockDemon = new Thread(new RedisLockDeamon(redisLockUtils));
        lockDemon.setDaemon(true);
        lockDemon.setName("Redis_Lock_Demon_Thread");
        lockDemon.start();
        log.info("分布式锁守护线程启动完成");
    }
}
